﻿using AutoMapper;
using Domain.Com;
using Domain.Draw;
using Domain.Sys;
using DTO.DTO.Com.BasicType;
using DTO.DTO.Draw.Entry;
using DTO.DTO.Sys.AdminUser;
using DTO.DTO.Sys.Module;
using DTO.DTO.Sys.Role;

namespace Web.Framework
{
    public class AutoMapperProfile : Profile
    {
        public AutoMapperProfile()
        {
            AddGlobalIgnore("IsDelete");
            AddGlobalIgnore("CreateUserId");
            AddGlobalIgnore("CreateTime");
            AddGlobalIgnore("UpdateUserId");
            AddGlobalIgnore("UpdateTime");
            CreateMap<AdminUser, AdminUserListDTO>()
             .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(p => p.CreateTime));
            CreateMap<AdminUser, AdminUserDetailDTO>();
            CreateMap<AdminUserDetailDTO, AdminUser>();

            CreateMap<Role, RoleListDTO>()
             .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(p => p.CreateTime));
            CreateMap<Role, RoleDetailDTO>();
            CreateMap<RoleDetailDTO, Role>();

            CreateMap<Module, ModuleListDTO>()
             .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(p => p.CreateTime));
            CreateMap<Module, ModuleFullDTO>()
             .ForMember(dest => dest.FullPath, opt => opt.Ignore());
            CreateMap<Module, ModuleDetailDTO>();
            CreateMap<ModuleDetailDTO, Module>()
             .ForMember(dest => dest.Depth, opt => opt.Ignore());

            CreateMap<BasicType, BasicTypeListDTO>()
             .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(p => p.CreateTime));
            CreateMap<BasicType, BasicTypeDetailDTO>();
            CreateMap<BasicTypeDetailDTO, BasicType>();

            CreateMap<Entry, EntryListDTO>()
             .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(p => p.CreateTime));
            CreateMap<Entry, EntryDetailDTO>();
            CreateMap<EntryDetailDTO, Entry>();
        }
    }
}